package com.qfedu.controller;

import com.qfedu.entity.User;
import com.qfedu.service.intf.UserService;
import com.qfedu.vo.PageVo;
import com.qfedu.vo.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api/user/")
public class UserController {
    @Resource
    private UserService service;

    @PostMapping("add.do")
    public R add(User user){
        return service.add(user);
    }
    @PostMapping("update.do")
    public R update(User user){
        return service.update(user);
    }
    @PostMapping("delete.do")
    public R delete(int id, HttpSession session){
        return service.delete(id);
    }
    @GetMapping("page.do")
    public PageVo page(String name, String phone, int page, int limit){
        return service.queryPage(name, phone, page, limit);
    }
    @PostMapping("login.do")
    public R login(String name,String password,String code,HttpSession session){
        System.out.println(name);
        System.out.println(password);
        System.out.println(code);
        System.out.println(session);
        return service.login(name, password, code, session);
    }
}
